package com.ruoyi.web.controller.djb;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.djb.domain.DjbShareInfo;
import com.ruoyi.djb.service.IDjbShareInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分享管理Controller
 * 
 * @author xxd
 * @date 2024-01-02
 */
@Controller
@RequestMapping("/djb/shareInfo")
public class DjbShareInfoController extends BaseController
{
    private String prefix = "djb/shareInfo";

    @Autowired
    private IDjbShareInfoService djbShareInfoService;

    @RequiresPermissions("djb:shareInfo:view")
    @GetMapping()
    public String shareInfo()
    {
        return prefix + "/shareInfo";
    }

    /**
     * 查询分享管理列表
     */
    @RequiresPermissions("djb:shareInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjbShareInfo djbShareInfo)
    {
        startPage();
        List<DjbShareInfo> list = djbShareInfoService.selectDjbShareInfoList(djbShareInfo);
        return getDataTable(list);
    }

    /**
     * 导出分享管理列表
     */
    @RequiresPermissions("djb:shareInfo:export")
    @Log(title = "分享管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjbShareInfo djbShareInfo)
    {
        List<DjbShareInfo> list = djbShareInfoService.selectDjbShareInfoList(djbShareInfo);
        ExcelUtil<DjbShareInfo> util = new ExcelUtil<DjbShareInfo>(DjbShareInfo.class);
        return util.exportExcel(list, "分享管理数据");
    }

    /**
     * 新增分享管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存分享管理
     */
    @RequiresPermissions("djb:shareInfo:add")
    @Log(title = "分享管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjbShareInfo djbShareInfo)
    {
        return toAjax(djbShareInfoService.insertDjbShareInfo(djbShareInfo));
    }

    /**
     * 修改分享管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DjbShareInfo djbShareInfo = djbShareInfoService.selectDjbShareInfoById(id);
        mmap.put("djbShareInfo", djbShareInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存分享管理
     */
    @RequiresPermissions("djb:shareInfo:edit")
    @Log(title = "分享管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjbShareInfo djbShareInfo)
    {
        return toAjax(djbShareInfoService.updateDjbShareInfo(djbShareInfo));
    }

    /**
     * 删除分享管理
     */
    @RequiresPermissions("djb:shareInfo:remove")
    @Log(title = "分享管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(djbShareInfoService.deleteDjbShareInfoByIds(ids));
    }
}
